<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>网站信息</title>
    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/admin.css">
    <script src="../js/jquery.js"></script>
    <script src="../js/pintuer.js"></script>
    <script src="../js/jquery.form.js"></script>
</head>

<body>
    <div id="info"></div>
    <div class="panel admin-panel">
        <div class="panel-head"><strong><span class="icon-pencil-square-o"></span>添加座子</strong></div>
        <div class="body-content">
            <form class="form-x" id="assetForm" enctype="multipart/form-data">
                <div class="form-group">
                    <div class="label">
                        <label>ID：</label>
                    </div>
                    <div class="field">
                        <input type="text" id="url7" name="id" class="input tips" style="width:25%; float:left;" value="" />
                        <div class="tips"></div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>桌图URL：</label>
                    </div>
                    <div class="field">
                        <input type="text" id="url1" name="icon" class="input tips" style="width:25%; float:left;"
                            value="https://miao.su/images/2019/01/10/3e148ebad47b0736e139f.png" />
                        <div class="tips"></div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>桌名：</label>
                    </div>
                    <div class="field">
                        <input type="text" id="url2" name="text" class="input tips" style="width:25%; float:left;"
                            value="" />
                        <div class="tips"></div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>状态：</label>
                    </div>
                    <div class="field">
                        <input type="text" id="url3" name="status" class="input tips" style="width:25%; float:left;"
                            value="0" />
                        <div class="tips"></div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label></label>
                    </div>
                    <div class="field" style="margin-top: 20px">
                        <button class="button bg-main icon-check-square-o" type="button" id="agreementSub">添加</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>
<script>
    $(document).ready(function () {
        $('#agreementSub').on('click', function () {
            $('#assetForm').ajaxSubmit({
                url: 'http://127.0.0.1:8080/wineapi/tableadd',
                type: 'get',
                dataType: 'json',
                data: $('#assetForm').serialize(),
                success: function (data) {
                    console.log(data)
                    if (data.code == "ok") {
                        window.location.href = "../components/table.html"
                    } else {
                        var str =
                            `
                                <div class="alert alert-red">
                                    <span class="close rotate-hover"></span><strong>错误：</strong>没有该ID。
                                </div>
                            `
                        $('#info').html(str)
                        setTimeout(function () {
                            $('#info').html('')
                        }, 2000)
                    }
                },
                error: function (err) {
                    console.log(err)
                },
                clearForm: false, //禁止清除表单
                resetForm: false //禁止重置表单
            })
        })
    })
</script>

</html>